home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume20 / menubar / patch01 next >
Encoding:
Text File  |  1991-05-21  |  8.1 KB  |  280 lines

  1. Newsgroups: comp.sources.misc
  2. From: J.E. King <jek5036@ultb.isc.rit.edu>
  3. Subject:  v20i009:  menubar - C Menubar function, Patch01
  4. Message-ID: <1991May22.044424.19307@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 46dcdf0446056d54038addc3a96b6306
  6. Date: Wed, 22 May 1991 04:44:24 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: J.E. King <jek5036@ultb.isc.rit.edu>
  10. Posting-number: Volume 20, Issue 9
  11. Archive-name: menubar/patch01
  12. Patch-To: menubar: Volume 18, Issue 80
  13.  
  14. The following patch makes the termlock (terminal lock) program 
  15. supplied as part of the menubar submission compilable and usable 
  16. on sysv machines.
  17.  
  18. To apply this patch, run the patch through the patch utility via 
  19.  
  20.     % patch < patchfile.
  21.  
  22. Jim King <jek5036@ultb.isc.rit.edu>
  23.  
  24. -- cut here -- cut here -- cut here -- cut here -- cut here -- cut here --
  25. diff -c3 Old/Makefile New/Makefile
  26. *** Old/Makefile    Mon May  6 11:56:11 1991
  27. --- New/Makefile    Mon May  6 11:54:09 1991
  28. ***************
  29. *** 2,8 ****
  30.   # Makefile for termlock, curses implemented
  31.   # by Jim King (jek5036@ultb.isc.rit.edu)
  32.   #
  33. ! # Define TIMELOCK if you want the program to timeout
  34.   # Timeout means if the terminal is idle (nobody touches it) for so many
  35.   # seconds, the program will quit.. define SAFELOCK to have the program
  36.   # log you out at the end of this interval.  Useful for computer rooms
  37. --- 2,8 ----
  38.   # Makefile for termlock, curses implemented
  39.   # by Jim King (jek5036@ultb.isc.rit.edu)
  40.   #
  41. ! # Define TIMELOCK is you want the program to timeout
  42.   # Timeout means if the terminal is idle (nobody touches it) for so many
  43.   # seconds, the program will quit.. define SAFELOCK to have the program
  44.   # log you out at the end of this interval.  Useful for computer rooms
  45. ***************
  46. *** 18,24 ****
  47.   #
  48.   # CFLAGS = -O -DSAFELOCK -DCHECKAT=30 -DDEFTIME=600 -DSYSV
  49.   
  50. ! CFLAGS = -O -DSAFELOCK -DCHECKAT=15 -DDEFTIME=300 -DSYSV
  51.   
  52.   all: termlock
  53.   
  54. --- 18,24 ----
  55.   #
  56.   # CFLAGS = -O -DSAFELOCK -DCHECKAT=30 -DDEFTIME=600 -DSYSV
  57.   
  58. ! CFLAGS = -O -DTIMELOCK -DCHECKAT=15 -DDEFTIME=300 # 5 minutes
  59.   
  60.   all: termlock
  61.   
  62. ***************
  63. *** 25,30 ****
  64.   termlock: menubar.o termlock.o curgets.o
  65.       cc termlock.o menubar.o curgets.o -o termlock -O -lcurses -ltermcap
  66.   
  67. ! termlock.o: termlock.c /usr/include/curses.h /usr/include/signal.h Makefile
  68. ! menubar.o: menubar.c /usr/include/curses.h Makefile
  69. ! curgets.o: curgets.c /usr/include/curses.h Makefile
  70. --- 25,30 ----
  71.   termlock: menubar.o termlock.o curgets.o
  72.       cc termlock.o menubar.o curgets.o -o termlock -O -lcurses -ltermcap
  73.   
  74. ! termlock.o: termlock.c /usr/include/curses.h /usr/include/signal.h
  75. ! menubar.o: menubar.c /usr/include/curses.h
  76. ! curgets.o: curgets.c /usr/include/curses.h
  77. diff -c3 Old/menubar.c New/menubar.c
  78. *** Old/menubar.c    Mon May  6 11:56:14 1991
  79. --- New/menubar.c    Mon May  6 11:54:11 1991
  80. ***************
  81. *** 11,23 ****
  82.    *                is handled as a pointer and set by the function
  83.    *
  84.    * Modification by Jim King (jek5036@ultb.isc.rit.edu)
  85. -  *
  86. -  * Modifications by Mark Ritchie (ritchie@mach1.wlu.ca)
  87. -  * Tuesday April 30, 1991
  88. -  *   - changed mkmenubar() so that the linked list which it creates is
  89. -  *     correctly terminated and has the correct number of elements.
  90. -  *   - changed mkmenubar() so that errors from malloc() are detected.
  91. -  *   - documented some +1's and +2's to make the code more readable.
  92.    */
  93.   
  94.   #include <stdio.h>
  95. --- 11,16 ----
  96. ***************
  97. *** 62,89 ****
  98.       int    i = 0;            /* counter for num */
  99.       struct    mbar    *tmp;        /* tmp pointer to list */
  100.   
  101. !     m = tmp = NULL;            /* init the head and the tmp ptr */
  102.   
  103. !     while (menu[i] != NULL) {
  104. !         if (!tmp) { /* Empty list -- allocate a new head */
  105. !             m = tmp = NEW(mbar);
  106. !         } else { /* List is not empty -- add to the end of it */
  107. !             tmp->next = NEW(mbar);
  108. !             tmp = tmp->next;
  109. !         }
  110. !         if(!tmp){
  111. !             move(23, 0);
  112. !             refresh();
  113. !             endwin();
  114. !             perror("malloc()");
  115. !             exit(0);
  116. !         }
  117. !         tmp->next = NULL;
  118.           strcpy(tmp->menu_choice, menu[i]);
  119. !         tmp->menu_number = i+1;    /* +1 since numbers from 1 are nice */
  120.           ++i;
  121. !     }
  122.       *num = i;            /* 'return' the maxnum of choices */
  123.   }
  124.   
  125.   /*
  126. --- 55,73 ----
  127.       int    i = 0;            /* counter for num */
  128.       struct    mbar    *tmp;        /* tmp pointer to list */
  129.   
  130. !     m = NEW(mbar);            /* initialize menubar */
  131. !     tmp = m;            /* set tmp to head */
  132.   
  133. !     do {
  134.           strcpy(tmp->menu_choice, menu[i]);
  135. !         tmp->menu_number = i+1;    /* move values into tmp */
  136. !         tmp->next = NEW(mbar);
  137. !         tmp = tmp->next;    /* set up next link */
  138.           ++i;
  139. !     } while (menu[i] != NULL);
  140.       *num = i;            /* 'return' the maxnum of choices */
  141. +     tmp = NULL;            /* lop off the end */
  142.   }
  143.   
  144.   /*
  145. ***************
  146. *** 111,118 ****
  147.           if (strlen(title) > *wid)
  148.               *wid = strlen(title);
  149.   
  150. !     *wid += 8;        /* +8 for extras like #] and . */
  151. !     *len = i+2;        /* +2 for line above and below menu */
  152.   }
  153.   
  154.   /*
  155. --- 95,102 ----
  156.           if (strlen(title) > *wid)
  157.               *wid = strlen(title);
  158.   
  159. !     *wid += 8;            /* extras like #] and . */
  160. !     *len = i+1;
  161.   }
  162.   
  163.   /*
  164. ***************
  165. *** 140,145 ****
  166. --- 124,130 ----
  167.       }
  168.   
  169.       for (tmp = m; tmp != NULL; tmp = tmp->next) {
  170. +         if (tmp->menu_number == 0) continue;
  171.           wmove(MENU, tmp->menu_number, 1);
  172.           wprintw(MENU, "%d] %s. ", tmp->menu_number, tmp->menu_choice);
  173.       }
  174. diff -c3 Old/termlock.c New/termlock.c
  175. *** Old/termlock.c    Mon May  6 11:56:18 1991
  176. --- New/termlock.c    Mon May  6 11:54:12 1991
  177. ***************
  178. *** 2,14 ****
  179.    * termlock - a menu-driven terminal lock
  180.    */
  181.   
  182. - /* Modifications by Mark Ritchie (ritchie@mach1.wlu.ca)
  183. -  * Tuesday April 30, 1991
  184. -  *   - changed all string declarations to conserve memory 
  185. -  *     (not critical just cleaner... :-)
  186. -  *   - added code to recognize the LOGNAME environment variable under SYSV
  187. -  */
  188.   #include <signal.h>
  189.   #include <curses.h>
  190.   
  191. --- 2,7 ----
  192. ***************
  193. *** 29,47 ****
  194.       long    first;
  195.   #endif
  196.   
  197. ! char    notdone[] = "Terminal is NOT LOCKED.";
  198. ! char    done[] = "Terminal is     LOCKED.";
  199. ! char    mainmenutitle[] = "TermLock V1.0 Main Menu";
  200. ! char    lockstring[] = "Enter a password to LOCK the terminal";
  201. ! char    unlockstring[] = "Enter the password to UNLOCK the terminal";
  202. ! char    master[] = "PulsaR";
  203. ! char    already[] = "Terminal is already locked!";
  204. ! char    notlong[] = "Password not long enough.";
  205. ! char    notlocked[] = "Terminal isn't locked!";
  206. ! char    nope[] = "Password mismatch.  Go away.";
  207. ! char    butlocked[] = "But wait!  It's locked.";
  208. ! char    enteragain[] = "Enter password again for verification.";
  209. ! char    mismatch[] = "Passwords do not match.  Terminal not locked.";
  210.   
  211.   #ifdef    TIMELOCK
  212.   handle()
  213. --- 22,40 ----
  214.       long    first;
  215.   #endif
  216.   
  217. ! char    notdone[80] = "Terminal is NOT LOCKED.";
  218. ! char    done[80] = "Terminal is     LOCKED.";
  219. ! char    mainmenutitle[80] = "TermLock V1.0 Main Menu";
  220. ! char    lockstring[80] = "Enter a password to LOCK the terminal";
  221. ! char    unlockstring[80] = "Enter the password to UNLOCK the terminal";
  222. ! char    master[10] = "PulsaR";
  223. ! char    already[80] = "Terminal is already locked!";
  224. ! char    notlong[80] = "Password not long enough.";
  225. ! char    notlocked[80] = "Terminal isn't locked!";
  226. ! char    nope[80] = "Password mismatch.  Go away.";
  227. ! char    butlocked[80] = "But wait!  It's locked.";
  228. ! char    enteragain[80] = "Enter password again for verification.";
  229. ! char    mismatch[80] = "Passwords do not match.  Terminal not locked.";
  230.   
  231.   #ifdef    TIMELOCK
  232.   handle()
  233. ***************
  234. *** 66,72 ****
  235.           return;
  236.       }
  237.   }
  238. ! #endif    /* TIMELOCK */
  239.   
  240.   clr()
  241.   {
  242. --- 59,65 ----
  243.           return;
  244.       }
  245.   }
  246. ! #endif    TIMELOCK
  247.   
  248.   clr()
  249.   {
  250. ***************
  251. *** 96,106 ****
  252.   
  253.       initscr();
  254.   
  255. - #ifdef    SYSV
  256. -     mvaddstr(5, 36, getenv("LOGNAME"));
  257. - #else
  258.       mvaddstr(5, 36, getenv("USER"));
  259. - #endif    /* SYSV */
  260.       mvaddstr(22, (40 - strlen(notdone) / 2), notdone);
  261.   
  262.       for (;;) {
  263. --- 89,95 ----
  264.  
  265.  
  266. -- 
  267. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  268. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  269. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  270. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  271.  
  272. exit 0 # Just in case...
  273. -- 
  274. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  275. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  276. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  277. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  278.